package main

import "fmt"

// func insertSort(inList []int) {
//     listLength := len(inList)
//     for j := 0; j < listLength; j++ {
//         for i := j + 1; i < listLength; i++ {
//             if inList[i] < inList[j] {
//                 inList[i], inList[j] = inList[j], inList[i]
//             }
//         }
//     }
//     fmt.Println(inList)

// }

func bubbleSort(inList []int) {
	listLength := len(inList)
OUT:
	for j := 0; j < listLength; j++ {
		flag := true
		for i := j; i < listLength-1; i++ {
			if inList[i] > inList[i+1] {
				inList[i], inList[i+1] = inList[i+1], inList[i]
				flag = false
			}
		}
		if flag {
			break OUT
		}
	}
	fmt.Println(inList)

}

func main() {
	inList := []int{2, 5, 234, 5, 23, 6, 789, 34, 57, 213}
	bubbleSort(inList)
	// insertSort(inList)
}
